home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / D4DATA.H < prev    next >
C/C++ Source or Header  |  1993-07-26  |  57KB  |  1,540 lines

  1. /* d4data.h   (c)Copyright Sequiter Software Inc., 1990-1993.  All rights reserved. */
  2.  
  3. #ifndef S4MDX
  4. #ifndef S4FOX
  5. #ifndef S4CLIPPER
  6. #ifndef S4NDX
  7.    #error - Must compile with one of the indexing options (S4MDX, S4FOX, S4CLIPPER, OR S4NDX)
  8. #endif
  9. #endif
  10. #endif
  11. #endif
  12.  
  13. #ifdef S4MDX
  14. #ifdef S4FOX
  15.    #error - Both S4MDX and S4FOX switches set - only one is allowed.
  16. #endif
  17. #ifdef S4CLIPPER
  18.    #error - Both S4MDX and S4CLIPPER switches set - only one is allowed.
  19. #endif
  20. #ifdef S4NDX
  21.    #error - Both S4MDX and S4NDX switches set - only one is allowed.
  22. #endif
  23. #endif
  24.  
  25. #ifdef S4FOX
  26. #ifdef S4CLIPPER
  27.    #error - Both S4FOX and S4CLIPPER switches set - only one is allowed.
  28. #endif
  29. #ifdef S4NDX
  30.    #error - Both S4FOX and S4NDX switches set - only one is allowed.
  31. #endif
  32. #endif
  33.  
  34. #ifdef S4CLIPPER
  35. #ifdef S4NDX
  36.    #error - Both S4CLIPPER and S4NDX switches set - only one is allowed.
  37. #endif
  38. #endif
  39.  
  40. #ifndef S4UNIX
  41. #ifndef _SIZE_T_DEFINED_     /* Watcom */
  42. #ifndef _SIZE_T_DEFINED      /* Microsoft, Metaware */
  43. #ifndef _SIZE_T              /* Borland  */
  44.    typedef unsigned size_t ;
  45.    #define _SIZE_T_DEFINED_           /* Used to resolve Watcom 386 warning */
  46.    #define _SIZE_T
  47. #endif
  48. #endif
  49. #endif
  50. #endif
  51.  
  52. #ifndef _A_RDONLY
  53.    #define _A_RDONLY 0x01                  /* Read-only attribute  */
  54. #endif
  55.  
  56. #ifdef __HIGHC__           /* align structures to word alignment, Metaware */
  57.   #pragma Align_members(2) 
  58. #endif
  59.  
  60.                            /* Foreign language support */
  61. #ifdef S4GERMAN
  62.    #define S4LANGUAGE
  63. #endif   
  64.  
  65. #ifdef S4FRENCH
  66.    #define S4LANGUAGE
  67. #endif
  68.  
  69. #ifdef S4SCANDINAVIAN
  70.    #define S4LANGUAGE
  71. #endif
  72.  
  73. #ifdef __TURBOC__
  74.    #ifdef S4DLL
  75.       #define S4CLASS huge
  76.       #define S4FUNCTION far pascal
  77.    #endif
  78. #endif
  79.  
  80. #ifdef _MSC_VER
  81.    #ifdef S4DLL
  82.       #ifdef __cplusplus
  83.          #define S4CLASS
  84.       #else
  85.          #define S4CLASS huge
  86.       #endif
  87.       #define S4FUNCTION far pascal
  88.    #endif
  89. #endif
  90.  
  91. #ifdef __ZTC__
  92.    #ifdef S4DLL
  93.       #ifdef __cplusplus
  94.          #define S4CLASS
  95.       #else
  96.          #define S4CLASS huge
  97.       #endif
  98.       #define S4FUNCTION far pascal
  99.    #endif
  100. #endif
  101.  
  102. #ifdef S4DLL_BUILD
  103.     #define S4WINDOWS 32
  104.    #define __DLL__ 1
  105. #endif
  106.  
  107. #ifndef __OS2__
  108. #ifdef __DLL__
  109.     #define S4DLL 16
  110.     #define S4CLASS _export
  111.     #define S4FUNCTION far pascal _export
  112. #endif
  113. #endif
  114.  
  115. #ifndef S4CLASS
  116.    #define S4CLASS
  117.    #define S4FUNCTION
  118. #endif
  119.  
  120. #ifdef S4DLL
  121.     #define S4WINDOWS 32
  122.    #define S4CALL far pascal _export
  123. #else
  124.    #ifdef _MSC_VER
  125.       #define S4CALL _cdecl S4FUNCTION
  126.    #else
  127.       #define S4CALL S4FUNCTION
  128.    #endif
  129. #endif
  130.  
  131. #ifdef S4WINDOWS
  132.    #define S4FLUSH             /* force automatic hard flush when write() called */
  133.    typedef unsigned int UINT ;
  134.    #define sprintf wsprintf
  135. #endif
  136.  
  137. #ifdef S4DLL
  138.    #define S4PTR far
  139. #else
  140.    #define S4PTR
  141. #endif
  142.  
  143. #ifdef S4NDX
  144.    #define N4OTHER
  145.    /* default is to use dBASE III+/Clipper memo file formats if using .NDX index file formats */
  146.    #define S4MNDX
  147. #endif
  148.  
  149. #ifdef S4CLIPPER
  150.    #define N4OTHER
  151.    /* default is to use dBASE III+/Clipper memo file formats if using .NTX index file formats */
  152.    #define S4MNDX
  153. #endif
  154.  
  155. #ifdef S4FOX
  156.    /* default is to use foxpro memo file formats if using foxpro index file formats */
  157.     #define S4MFOX
  158.    #define S4HAS_DESCENDING
  159. #endif
  160.  
  161. #ifdef S4MDX
  162.    #define S4MMDX
  163. #endif
  164.  
  165. #ifdef S4MNDX
  166.    #define   MEMO4SIZE   0x200
  167. #endif
  168.  
  169. #ifndef S4UNIX
  170.    typedef  const void S4PTR *  S4CMP_PARM ;
  171. #endif
  172.  
  173. typedef int S4CALL  S4CMP_FUNCTION( S4CMP_PARM, S4CMP_PARM, size_t) ;
  174.  
  175. #ifdef S4DLL
  176.    #define sort4assign_cmp(s4,f)  (s4)->cmp = (S4CMP_FUNCTION S4PTR *) MakeProcInstance((FARPROC) f, (s4)->code_base->hInst)
  177. #else
  178.    #define sort4assign_cmp(s4,f)  (s4)->cmp = (S4CMP_FUNCTION S4PTR *) (f)
  179. #endif
  180.  
  181. /* Integer Return Codes */
  182. #define r4success     0
  183. #define r4found       1       /* Primary Key Match */
  184. #define r4after       2
  185. #define r4eof         3
  186. #define r4bof         4
  187. #define r4entry       5       /* No index file entry or no record (go) */
  188. #define r4descending 10
  189. #define r4unique     20       /* Key is not unique, do not write/append */
  190. #define r4unique_continue  25 /* Key is not unique, write/append anyway */
  191. #define r4ignore     40
  192. #define r4keep       45
  193. #define r4locked     50
  194. #define r4no_create  60       /* Could not create file */
  195. #define r4no_open    70       /* Could not open file */
  196. #define r4no_tag     80       /* DataIndex::seek, with no default tag */
  197. #define r4terminate  90       /* no relation match with terminate set */
  198.  
  199. /* General Disk Access Errors */
  200. #define e4close   -10
  201. #define e4create  -20
  202. #define e4len     -30
  203. #define e4len_set -40
  204. #define e4lock    -50
  205. #define e4open    -60
  206. #define e4read    -70
  207. #define e4remove  -80
  208. #define e4rename  -90
  209. #define e4seek   -100
  210. #define e4unlock -110
  211. #define e4write  -120
  212.  
  213. /* Database Specific Errors */
  214. #define e4data  -200
  215. #define e4field_name -210     /* Invalid field name */
  216. #define e4field_type -220
  217. #define e4record_len -230
  218.  
  219. /* Index File Specific Errors */
  220. #define e4entry      -300     /* Tag entry not located */
  221. #define e4index      -310
  222. #define e4tag_name   -330
  223. #define e4unique     -340     /* Key is not unique */
  224.  
  225. /* Expression Errors */
  226. #define e4comma_expected -400
  227. #define e4complete       -410
  228. #define e4data_name      -420
  229. #define e4length_err     -422
  230. #define e4not_constant   -425
  231. #define e4num_parms      -430
  232. #define e4overflow       -440 /* Overflow while evaluating expression */
  233. #define e4right_missing  -450
  234. #define e4type_sub       -460
  235. #define e4unrec_function -470
  236. #define e4unrec_operator -480
  237. #define e4unrec_value    -490
  238. #define e4unterminated   -500
  239.  
  240. /* Optimization Errors */
  241. #define e4opt         -610
  242. #define e4opt_suspend -620
  243. #define e4opt_flush   -630
  244.  
  245. /* Relation Errors */
  246. #define e4lookup_err  -710
  247. #define e4relate      -720
  248.  
  249. /* Report Errors */
  250. #define e4report  -810
  251.  
  252. /* Critical Errors */
  253. #define e4info     -910  /* Unexpected information in internal variable */
  254. #define e4memory   -920  /* Out of memory */
  255. #define e4parm     -930  /* Unexpected parameter */
  256. #define e4demo     -940  /* Exceeded maximum record number for demo */
  257. #define e4result   -950  /* Unexpected result */
  258.  
  259. #define E4DEMO_MAX 200
  260.  
  261. /* garbage between expression and filter is length: */
  262. #ifdef  S4FOX
  263.    #define I4MULTIPLY       1
  264.    #define B4DO_BACK_LEVEL  3
  265.    #define I4MAX_KEY_SIZE 240
  266. #else
  267.    #define I4MULTIPLY     512
  268.  
  269.    #ifdef S4NDX
  270.       #define I4MAX_KEY_SIZE 100
  271.    #else
  272.       #ifdef S4CLIPPER
  273.          #define I4MAX_KEY_SIZE 338
  274.       #else
  275.          #define I4MAX_KEY_SIZE 102
  276.       #endif
  277.    #endif
  278. #endif
  279.  
  280. #define D4GARBAGE_LEN  518
  281. #define E4ACCURACY     1.0e-13
  282. #define E4ACCURACY_DIGITS  15
  283.  
  284.  
  285. #ifdef N4OTHER
  286.    #define L4LOCK_POS     1000000000L
  287. #endif
  288. #ifdef S4FOX
  289.    #define L4LOCK_POS_OLD 0x40000000L
  290.    #define L4LOCK_POS     0x7FFFFFFEL
  291. #endif
  292. #ifdef S4MDX
  293.    #define L4LOCK_POS_OLD 0x40000000L
  294.    /* if S4NO_NEGATIVE_LOCK is defined, there is no dBASE IV compatibility */
  295.    #ifdef S4NO_NEGATIVE_LOCK
  296.       #define L4LOCK_POS     0x7FFFFFFFL
  297.    #else
  298.       #define L4LOCK_POS     0xEFFFFFFFUL
  299.    #endif
  300. #endif
  301.  
  302. typedef void C4STOK( char S4PTR *, char S4PTR *, int ) ;
  303. typedef void C4DTOK( char S4PTR *, double ) ;
  304.  
  305. struct DATA4_st ;
  306. struct F4MEMO_st ;
  307. struct INDEX4_st ;
  308. struct TAG4_st ;
  309. struct FILE4_st ;
  310. #ifdef __cplusplus
  311.    struct S4CLASS CODE4_st ;
  312. #else
  313.    struct CODE4_st ;
  314. #endif
  315.  
  316. typedef struct l4link_st
  317. {
  318.    struct l4link_st S4PTR *n, S4PTR *p ;
  319. } LINK4 ;
  320.  
  321. #ifdef __cplusplus
  322.    typedef struct S4CLASS
  323. #else
  324.    typedef struct
  325. #endif
  326. {
  327.    LINK4 S4PTR *last ;        /* The last Link */
  328.    void   S4PTR *selected ;
  329.    int     n_link ;            /* The number of links in the list */
  330. } LIST4 ;
  331.  
  332. typedef struct
  333. {
  334.    LINK4 link ;
  335.    double  data ;  /* Make sure it is on a boundry good for at least a double  */
  336. } Y4CHUNK ;
  337.  
  338. typedef struct
  339. {
  340.    LINK4      link ;
  341.  
  342.    LIST4      chunks ;      /* Chunks of pieces */
  343.    LIST4      pieces ;      /* A list of available memory pieces */
  344.  
  345.    struct CODE4_st     *code_base ;
  346.  
  347.    int        unit_start;   /* The starting # of entries for the Memory Type */
  348.    unsigned   unit_size ;   /* The size of each allocated piece */
  349.    int        unit_expand ; /* The expansion # of entries for the Memory Type */
  350.    int        n_repeat ;    /* The number of times entry returned for 'new' */
  351.                              /* If n_repeat is '-1', it is a temporary entry. */
  352.    int        n_used ;      /* The number of entries used */
  353. }  MEM4 ;
  354.  
  355. #ifdef __cplusplus
  356.    typedef struct S4CLASS
  357. #else
  358.    typedef struct
  359. #endif
  360. {
  361.    int              num_buffers ;
  362.    unsigned long    block_size ;
  363.    unsigned long    buffer_size ;
  364.    unsigned long    hash_trail ;       /* where last optimized file ended */
  365.    unsigned long    num_blocks ;
  366.  
  367.    LIST4            avail ;
  368.    LIST4            dbf_lru ;
  369.    LIST4            index_lru ;
  370.    LIST4            other_lru ;
  371.    LIST4           *prio[3] ;
  372.  
  373.    unsigned char    old_mode ;
  374.    unsigned char    do_update ;
  375.    unsigned char    check_count ;
  376.    int              min_link ;
  377.    void           **buffers ;
  378.    struct OPT4BLOCK_st *blocks ;
  379.    char             block_power ;
  380.    unsigned long    num_lists ;
  381.    unsigned long    mask ;
  382.    LIST4           *lists ;
  383.    char             num_shift ;
  384.    unsigned         max_blocks ;
  385.  
  386.    LIST4            opt_files ;
  387.  
  388.    char             is_skip ;
  389.    char             force_current ;    /* switch forces a read of current contents */
  390.  
  391.    char             *read_buffer ;
  392.    char             *write_buffer ;
  393.    unsigned long     write_start_pos ;
  394.    unsigned long     write_cur_pos ;
  395.    unsigned          write_block_count ; /* is the buffer full? */
  396.    struct FILE4_st  *write_file ;        /* which file has the write buffer? */
  397. } OPT4 ;
  398.  
  399. #ifdef __cplusplus
  400.    typedef struct S4CLASS CODE4_st
  401. #else
  402.    typedef struct CODE4_st
  403. #endif
  404. {
  405.    #ifndef S4OPTIMIZE_OFF
  406.       int  optimize_write ;
  407.       OPT4 opt ;
  408.       int  has_opt, do_opt ;
  409.       unsigned char     mode ;
  410.    #endif
  411.  
  412.    #ifdef S4CLIPPER
  413.       int numeric_str_len ;    /* the default length for clipper index files */
  414.       int decimals ;           /* the default # decimals for clipper index files */
  415.    #endif
  416.  
  417.    unsigned hWnd ;                /* For use under Microsoft Windows */
  418.    unsigned hInst ;
  419.  
  420.    LIST4   data_list ;           /* A list of open data files. */
  421.    int default_unique_error ;     /* e4unique, r4unique, r4unique_continue */
  422.    char date_format[19];          /* Longest is September 15, 1990 */
  423.  
  424.    unsigned mem_size_block ;      /* Block size (bytes) for memo and index files */
  425.    unsigned mem_size_sort_pool ;  /* The default pool size for sorting */
  426.    unsigned mem_size_sort_buffer ;/* The default file buffer size when sorting */
  427.    unsigned mem_size_buffer ;     /* Pack, Zap */
  428.    unsigned mem_size_memo ;
  429.  
  430.    int mem_expand_block ;         /* Expanding block memory allocation */
  431.    int mem_expand_data ;          /* Expanding data file allocation */
  432.    int mem_expand_index ;         /* Expanding index file allocation */
  433.    int mem_expand_tag ;           /* Expanding index file allocation */
  434.  
  435.    unsigned mem_start_data ;           /* Initial data file allocation */
  436.    unsigned mem_start_block ;          /* Initial block memory allocation for index files */
  437.    unsigned mem_start_index ;          /* Initial index file allocation */
  438.    unsigned mem_start_tag ;            /* Initial index file allocation */
  439.    unsigned mem_start_buffer ;
  440.    unsigned long mem_start_max ;
  441.  
  442.    /* True/False Flags */
  443.    int  auto_open ;            /* Automatic production index file opening */
  444.    int  create_error ;         /* Do 'file4create' error ? */
  445.    int  exclusive ;            /* how should files be opened? */
  446.    int  expr_error ;
  447.    int  field_name_error ;
  448.    int  go_error ;             /* Do 'd4go' error ? */
  449.    int  open_error ;           /* Do 'file4open' error ? */
  450.    int  optimize ;             /* should files be automatically bufferred? */
  451.    int  read_lock ;            /* Do lock when reading database ? */
  452.    int  read_only ;
  453.    int  relate_error ;         /* do relate4terminate error when no match and relate4terminate selected */
  454.    int  safety ;               /* File create with safety ? */
  455.    int  skip_error ;           /* Do 'DataIndex::skip' error ? */
  456.    int  tag_name_error;
  457.  
  458.    int  lock_attempts ;        /* How many times to attempt locks. */
  459.  
  460.    MEM4 S4PTR *index_memory ;
  461.    MEM4 S4PTR *data_memory ;
  462.    MEM4 S4PTR *tag_memory ;
  463.    MEM4 S4PTR *calc_memory ;
  464.    MEM4 S4PTR *bitmap_memory ;
  465.    LIST4 calc_list ;
  466.  
  467.    MEM4 *total_memory ;
  468.    LIST4  total_list ;       /* A list of T4TOTAL */
  469.    int  num_reports ;
  470.  
  471.    int  error_code ;
  472.    int  debug_int ;            /* used to check structure integrity (set to 0x5281) */
  473.  
  474.    short pageno;
  475.   
  476.    char  *field_buffer ;    /* used by the f4str() function */
  477.    unsigned  buf_len ;
  478.  
  479.    char *stored_key ;      /* used by the expr4key() function */
  480.    unsigned stored_key_len ;
  481.    char saved_key[I4MAX_KEY_SIZE + 2 * sizeof(long)] ;       /* used by i4remove.c, i4tag.c and i4addtag.c, i4version_check, t4version_check */
  482.  
  483.    int bitmap_disable ;     /* used for testing purposes to test disabled bitmaps */
  484.    int do_index_verify ;    /* for internal purposes only at this point */
  485. } CODE4 ;
  486.  
  487. typedef struct FILE4_st
  488. {
  489.    #ifndef S4OPTIMIZE_OFF
  490.       LINK4  link ;            /* set to 0 if file not optimized */
  491.       long   hash_init ;
  492.       long   len ;             /* internal if optimized */
  493.       char   type ;            /* dbf, index, other */
  494.       char   buffer_writes ;   /* are writes being bufferred? */
  495.       int    do_buffer ;       /* is the file bufferring on? */
  496.    #endif
  497.    char S4PTR *name ;
  498.    CODE4 S4PTR *code_base ;
  499.    int   hand ;
  500.    char  is_temp ;             /* True if it is a temporary file */
  501.  
  502.    /* is_exclusive and is_read_only both on indicate 'r' attribute on file */
  503.    /* is_read_only only on indicates user access is limited to read only */
  504.    /* if is_exclusive, will do full bufferring, if is_read_only, will avoid */
  505.    /* performing any disk writes */
  506.  
  507.    char  is_exclusive ;        /* True if opened exclusive */
  508.    char  is_read_only ;        /* True if file is read only */
  509.    char  do_alloc_free ;
  510.    char  write_buffer ;        /* buffer writes where possible */
  511.    char  file_created ;        /* false if the file has not been created yet - i.e. if a memory-only file */
  512. } FILE4 ;
  513.  
  514. typedef struct
  515. {
  516.    FILE4     file ;
  517.    short      block_size ;               /* Bytes */
  518.    struct DATA4_st  S4PTR *data ;
  519.    int      file_lock ;                  /* True if file is locked */
  520. } MEMO4FILE ;
  521.  
  522. typedef struct
  523. {
  524.    FILE4 S4PTR *file ;
  525.  
  526.    long  pos ;          /* The next position to read from */
  527.    char S4PTR *buffer ;
  528.    unsigned next_read_len ;
  529.    unsigned total ;     /* Total buffer length */
  530.    unsigned working ;   /* Temporary working buffer length (to help align write) */
  531.    unsigned avail ;     /* # of bytes currently available */
  532. } FILE4SEQ_READ ;
  533.  
  534. typedef struct
  535. {
  536.    FILE4 S4PTR *file ;
  537.  
  538.    long  pos ;          /* The next position to read from */
  539.    char S4PTR *buffer ;
  540.    unsigned total ;     /* Total buffer length */
  541.    unsigned working ;   /* Temporary working buffer length (to help align write) */
  542.    unsigned avail ;     /* # of bytes left in working buffer */
  543. } FILE4SEQ_WRITE ;
  544.  
  545. typedef struct  /* Data File Format */
  546. {
  547.    char     name[11] ;
  548.    char     type ;
  549.    char     filler[4] ;
  550.    unsigned char  len ;
  551.    unsigned char  dec ;
  552.    char     filler2[13] ;
  553.    char    has_tag ;
  554. } FIELD4IMAGE ;
  555.  
  556. typedef struct  /* Internal Structure and Field Routines. */
  557. {
  558.    char        name[11] ;
  559.    unsigned    len ;
  560.    int         dec ;
  561.    int         type ;
  562.    int         offset ;
  563.    struct DATA4_st  S4PTR *data ;
  564.    struct F4MEMO_st  S4PTR *memo ;
  565.    #ifdef S4VBASIC
  566.       int  debug_int ;         /* used to check structure integrity (set to 0x5281) */
  567.    #endif
  568. } FIELD4 ;
  569.  
  570. typedef struct F4MEMO_st
  571. {
  572.    int    is_changed ;
  573.  
  574.    int    status ;           /* 0 - Current contents, 1 - Unknown */
  575.    char  S4PTR *contents ;
  576.    unsigned  len ;
  577.    unsigned  len_max ;
  578.    FIELD4  S4PTR *field ;
  579. } F4MEMO ;
  580.  
  581. typedef struct  /* Creating Data File */
  582. {
  583.    char S4PTR  *name ;
  584.    char         type ;
  585.    unsigned int len ;
  586.    unsigned int dec ;
  587. } FIELD4INFO ;
  588.  
  589. typedef struct
  590. {
  591.    /* Database Header Information */
  592.    char     version ;        /* 83H with .dbt, 03H without */
  593.    char     yy ;             /* Last Update */
  594.    char     mm ;
  595.    char     dd ;
  596.    long     num_recs ;
  597.    unsigned short header_len; /* Header Length, Indicates start of data */
  598.    unsigned short record_len;
  599.    char     zero[16] ;
  600.    short    has_mdx ;    /* 1 for true */
  601.    char     zero2[2] ;
  602. } DATA4HEADER_FULL ;
  603.  
  604. typedef struct DATA4_st
  605. {
  606.    LINK4  link ;
  607.  
  608.    /* Database Header Information */
  609.    char     version ;        /* 83H with .dbt, 03H without */
  610.    char     yy ;             /* Last Update */
  611.    char     mm ;
  612.    char     dd ;
  613.    long     num_recs ;
  614.    unsigned short header_len; /* Header Length, Indicates start of data */
  615.  
  616.    char S4PTR *record ;              /* Data allocated with 'u4alloc' */
  617.    char S4PTR *record_old ;          /* Data allocated with 'u4alloc' */
  618.                                  /* Extra byte added for temporary CTRL_Z */
  619.    unsigned record_width ;
  620.    int      record_changed ;      /* T/F */
  621.    long     rec_num ;             /* Record number; -1 unknown; 0 for append */
  622.    long     rec_num_old ;         /* Record number, -1 none present; 0 for append */
  623.  
  624.    FILE4    file ;
  625.    char     alias[11] ;
  626.  
  627.    char     memo_validated ; /* Can we be sure memo id #'s are up to date. */
  628.  
  629.    CODE4 S4PTR *code_base ;
  630.    short    has_mdx ;        /* Has an MDX file attached to it */
  631.  
  632.    FIELD4  S4PTR *fields ;        /* An array of field pointers */
  633.    int      n_fields ;       /* The number of data fields in the database */
  634.  
  635.    F4MEMO   S4PTR *fields_memo ;    /* A list of fields to be flushed */
  636.    int      n_fields_memo ;  /* The number of memo files in the database */
  637.  
  638.    long     locked_record ;  /* 'locks' data when 'n_locks <= 1' */
  639.    long     S4PTR *locks ;
  640.    int      n_locks ;        /* Number of elements in 'locks' allocated */
  641.    int      num_locked ;     /* Number of records locked */
  642.    int      file_lock ;      /* True if entire file is locked */
  643.    int      append_lock ;    /* True if the file is locked for appending */
  644.  
  645.    int      file_changed ;   /* True if the file has been changed since */
  646.                                 /* the header has been updated. */
  647.  
  648.    LIST4    indexes ;
  649.    int      bof_flag, eof_flag ;    /* Beginning/End of File flags */
  650.  
  651.    short    block_size ;
  652.    MEMO4FILE   memo_file ;      /* Memo file handle */
  653.    #ifdef S4VBASIC
  654.       int   debug_int ;      /* used to check structure integrity (set to 0x5281) */
  655.    #endif
  656. } DATA4 ;
  657.  
  658. typedef struct e4expr_st
  659. {
  660.    struct E4INFO_st S4PTR *info ;
  661.    int      info_n ;
  662.    char S4PTR *source ;
  663.    char S4PTR *constants ;
  664.    int      len ;
  665.    int      type ;
  666.    #ifdef S4CLIPPER
  667.       int   key_dec ;         /* used for CLIPPER version */
  668.       int   key_len ;
  669.    #endif
  670.    DATA4  S4PTR *data ;
  671.    CODE4  S4PTR *code_base ;
  672.  
  673.    char  has_trim ;        /* special case for key evaluation */
  674.    int   len_eval ;        /* This is the length of the buffer needed for evaluation. */
  675.    int   num_parms ;       /* This is the # of parameter positions used in evaluation. */
  676. } EXPR4 ;
  677.  
  678. #ifdef N4OTHER
  679.    typedef struct
  680.    {
  681.       long  pointer ;    /* =0L if record, not pointer */
  682.       long  num ;
  683.       char  value[1] ;  /* The key size is variable */
  684.    } B4KEY_DATA ;
  685.  
  686.    #define I4MAX_EXPR_SIZE 256
  687.    #ifdef S4NDX
  688.       #define B4BLOCK_SIZE 512
  689.    #else
  690.       #ifdef S4CLIPPER
  691.          #define B4BLOCK_SIZE 1024
  692.       #endif
  693.    #endif
  694. #else
  695.    typedef struct
  696.    {
  697.       long  num ;
  698.       char  value[1] ;  /* The key size is variable */
  699.    } B4KEY_DATA ;
  700. #endif
  701.  
  702. #ifdef S4FOX
  703. //#define VERSION_POS 498L
  704.  
  705. /* the following structure is used only on the leaf nodes of the tree structure */
  706. typedef struct
  707. {
  708.    short            free_space ;        /* # bytes available in node */
  709.    unsigned long    rec_num_mask ;      /* record number mask */
  710.    unsigned char    dup_byte_cnt ;      /* duplicate byte mask count */
  711.    unsigned char    trail_byte_cnt ;    /* Trailing byte mask count */
  712.    unsigned char    rec_num_len ;       /* # bits used for record number */
  713.    unsigned char    dup_cnt_len ;       /* # bits used for duplicate count */
  714.    unsigned char    trail_cnt_len ;     /* # bits used for trail count */
  715.    unsigned char    info_len ;          /* # bytes for holding record number, */
  716. } B4NODE_HEADER ;
  717.  
  718. typedef struct
  719. {
  720.       short      node_attribute ;    /* 0=index, 1=root, 2=leaf */
  721.       short      n_keys ;            /* Block Image starts here */
  722.       long       left_node ;         /* -1 if not present */
  723.       long       right_node ;        /* -1 if not present */
  724. } B4STD_HEADER ;
  725.  
  726. typedef struct
  727. {
  728.    LINK4 link ;
  729.    struct TAG4_st  *tag ;
  730.  
  731.    int   changed ;
  732.    long  file_block ;     /* Identifies block within index file */
  733.    int   key_on ;         /* The current key within the block */
  734.    int   cur_trail_cnt ;  /* current value used for seeking */
  735.    int   cur_dup_cnt ;    /* current value used for seeking */
  736.    int   dup_pos ;        /* bit offset into the info for the duplicate data */
  737.    int   trail_pos ;      /* bit offset into the info for the trail data */
  738.    int   rec_pos ;        /* bit offset into the info for the record # data */
  739.    char  *cur_pos ;       /* current position into the data (starts at end) */
  740.  
  741.    int   built_on ;       /* the 'current' key value (i.e. key really 'on') */
  742.    char  *built_pos ;     /* position where built on */
  743.    B4KEY_DATA *built_key ;
  744.  
  745.    B4STD_HEADER header ;
  746.    B4NODE_HEADER node_hdr ;    /* only if the block is a leaf */
  747.    char  data[1] ;        /* the remaining data */
  748. } B4BLOCK ;
  749.  
  750. /* next is the # of bytes of important info for T4HEADER */
  751. #define T4HEADER_WR_LEN 0x10
  752. /* block_size is 512 for foxpro */
  753. #define B4BLOCK_SIZE 512
  754. #endif  /* ifdef S4FOX  */
  755.  
  756. #ifndef S4FOX
  757.  
  758. #ifdef S4NDX
  759.    typedef struct
  760.    {
  761.       long     root ;
  762.       long     eof ;
  763.       char     n1_dummy ;
  764.       char     type ;
  765.       char     n2_dummy[2] ;
  766.       short    key_len  ;
  767.       short    keys_max ;           /* Maximum # of keys per block;  <= 100 */
  768.       short    int_or_date ;        /* TRUE (1) if Numeric or Date Key */
  769.       short    group_len ;          /* key_len plus 8 increased to a multiple of 2 */
  770.       short    dummy ;
  771.       short    unique ;             /* TRUE if Unique */
  772.  
  773.  /*   char     expression[256] ; */
  774.  /*   long     version ; */
  775.    } I4IND_HEAD_WRITE;
  776. #else
  777.    #ifdef S4CLIPPER
  778.       typedef struct
  779.       {
  780.          short          sign ;
  781.          short          version ;
  782.          long           root ;          /* Root Block */
  783.          long           eof ;           /* First Free Block Pointer */
  784.          short          group_len ;     /* Key Length + 2*sizeof(long) */
  785.          short          key_len ;       /* Key Length */
  786.          short          key_dec ;       /* Number of Decimals in Key */
  787.          short          keys_max ;      /* Maximum # of keys per block;  <= 100 */
  788.          short          keys_half ;     /* Maximum # of keys per half block */
  789.  
  790.     /*   char           expression[256];   The index expression corresponding to the database. */
  791.     /*   short          unique   ;         TRUE if Unique */
  792.       } I4IND_HEAD_WRITE;
  793.    #endif
  794. #endif
  795.  
  796. #ifdef S4NDX
  797. typedef struct
  798. {
  799.    long     old_version ;
  800.    int      header_offset ;
  801.  
  802.    long     root ;
  803.    long     eof ;
  804.    char     n1_dummy ;
  805.    char     type ;
  806.    char     n2_dummy[2] ;
  807.    short    key_len  ;
  808.    short    keys_max ;           /* Maximum # of keys per block;  <= 100 */
  809.    short    int_or_date ;        /* TRUE (1) if Numeric or Date Key */
  810.    short    group_len ;          /* key_len plus 8 increased to a multiple of 2 */
  811.    short    dummy ;
  812.    short    unique ;             /* TRUE if Unique */
  813. /* char     expression[256] ; */
  814.    long     version ;
  815. }  T4HEADER ;
  816. #else
  817.    #ifdef S4CLIPPER
  818.       typedef struct
  819.       {
  820.          long       old_version ;
  821.          int        header_offset ;
  822.          long       virtual_eof ;   /* The next available file block */
  823.          short      sign ;
  824.          short      version ;
  825.          long       root ;          /* Root Block */
  826.          long       eof ;           /* First Free Block Pointer */
  827.          short      group_len ;     /* Key Length + 2*sizeof(long) */
  828.          short      key_len ;       /* Key Length */
  829.          short      key_dec ;       /* Number of Decimals in Key */
  830.          short      keys_max ;      /* Maximum # of keys per block;  <= 100 */
  831.          short      keys_half ;     /* Maximum # of keys per half block */
  832.       /* char       expression[256];   The index expression corresponding to the database. */
  833.          short      unique   ;      /* TRUE if Unique */
  834.       }  T4HEADER ;
  835.    #else
  836.       typedef struct
  837.       {
  838.          char   two ;                /* Version number (currently 2) */
  839.          char   yymmdd[3] ;          /* Date of last reindex */
  840.          char   data_name[12] ;      /* Name of associated data file */
  841.          char   dummy1[4] ;          /* extra 4 bytes for data-names-not used in DOS */
  842.          short  block_chunks ;       /* Block Size 1 to 32 (512 byte chunks) */
  843.          short  block_rw ;           /* Block Read/Write Size in bytes */
  844.          char   is_production ;      /* 1 if production index, else 0 */
  845.          char   num_slots ;          /* number possible tags (48) */
  846.          short  slot_size ;          /* number bytes/tag slot (32) */
  847.          long   num_tags ;
  848.          long   eof ;
  849.          long   free_list ;          /* start of the free list */
  850.          char   zero[4] ;
  851.          char   create_date[3];      /* not used by CodeBase++ */
  852.          char   blank ;
  853.       }  I4HEADER ;
  854.    #endif     /*   ifdef S4CLIPPER  */
  855. #endif     /*   ifdef S4NDX   */
  856. #endif     /*   ifndef S4FOX  */
  857.  
  858.  
  859. #ifndef S4FOX
  860. typedef struct
  861. {
  862.    LINK4 link ;
  863.    struct TAG4_st  S4PTR *tag ;
  864.  
  865.    long  file_block ;  /* Identifies block within index file */
  866.    int   changed ;
  867.    int   key_on ;      /* The current key within the block */
  868.  
  869.    short      n_keys ; /* Block Image starts here */
  870.    #ifdef S4NDX
  871.       char       dummy[2] ;
  872.       B4KEY_DATA data ;
  873.    #else
  874.       #ifdef S4CLIPPER
  875.          short pointers[( B4BLOCK_SIZE / 2 - 1 )] ;
  876.          B4KEY_DATA *data ;
  877.       #else
  878.          char       dummy[6] ;
  879.          B4KEY_DATA info ;
  880.       #endif
  881.    #endif
  882. } B4BLOCK ;
  883.  
  884. typedef struct
  885. {
  886.    long  header_pos ;          /* Header position (in 512 byte chunks) */
  887.    char  tag[10] ;
  888.    short x1000 ;               /* used for dBASE/SQL expression type - dBASE only allowed for CBPP 1.0x */
  889.    char  left_chld ;
  890.    char  right_chld ;
  891.    char  parent ;
  892.    char  x2 ;
  893.    char  index_type ;
  894.    char  zeros[11] ;
  895. } T4DESC ;
  896. #endif     /* ifndef  S4FOX  */
  897.  
  898. #ifndef N4OTHER
  899. typedef struct
  900. {
  901. #ifdef S4FOX
  902.    long           root ;            /* -1 means unknown */
  903.    long           free_list ;       /* start of the free list (-1 if none) */
  904.    unsigned long  version ;         /* used multi-user only */
  905.    short          key_len ;         /* Key Length */
  906.    unsigned char  type_code;        /* 0x01 Uniq; 0x08 For Clause; 0x32 Compact; 0x80 Compound */
  907.    unsigned char  signature ;       /* unused */
  908.  
  909. /* char           dummy2[482] ;        unused */
  910.    char           dummy3[4] ;
  911.    short          descending   ;    /* 1 = descending, 0 = ascending */
  912.    short          filter_pos ;      /* not used, == to expr_len */
  913.    short          filter_len ;      /* length of filter clause */
  914.    short          expr_pos ;        /* not used, == to 0  */
  915.    short          expr_len ;        /* length of expression */
  916. /* char           expr_pool[512] ;  expression and filter pool */
  917. #else
  918.    long           root ;            /* -1 means unknown */
  919.    char           dummy1[4] ;
  920.    char           type_code;        /* 0x10 Normal; 0x58 Uniq,Desc; 0x50 Uniq; 0x18 Desc */
  921.    char           type ;            /* N,D, or C (F is type N)  */
  922.    char           dummy2[2] ;
  923.    short          key_len ;
  924.    short          keys_max ;        /* Maximum # of keys per block;  <= 100  */
  925.    char           dummy3[2] ;       /* 1 if Numeric or Date Key (NDX only) */
  926.    short          group_len ;       /* key_len plus 4 (MDX); plus 8 (NDX) */
  927.    unsigned char  version ;
  928.    char           dummy4 ;
  929.    short          unique   ;        /* 0x4000 (TRUE)if Unique */
  930.  
  931.    /* Note, 'expr_key[220]' comes after 'unique' and */
  932.    /*       'expr_filter[220]' comes at position 0x2FA */
  933. #endif
  934. }  T4HEADER ;
  935. #endif   /*  ifndef N4OTHER  */
  936.  
  937. typedef struct TAG4_st
  938. {
  939.    LINK4           link ;
  940.  
  941.    EXPR4   S4PTR  *expr ;
  942.    EXPR4   S4PTR  *filter ;
  943.    int             unique_error; /* Is rewriting a unique key an error ? */
  944.    struct INDEX4_st S4PTR *index ;
  945.    S4CMP_FUNCTION *cmp ;
  946.    C4STOK S4PTR   *stok ;               /* Conversion for 'seek' */
  947.    C4DTOK S4PTR   *dtok ;               /* Conversion for 'seek' */
  948.    CODE4 S4PTR    *code_base ;
  949.    char            alias[11] ;
  950.    #ifdef S4MDX
  951.       char            had_keys ;
  952.    #endif
  953.    char            has_keys ;
  954.    LIST4           blocks ;
  955.  
  956.    #ifdef S4FOX
  957.       char         p_char ;
  958.    #endif
  959.  
  960.    #ifdef N4OTHER
  961.       FILE4        file ;
  962.       int          file_locked ;
  963.    #endif
  964.  
  965.    T4HEADER    header ;
  966.    long        header_offset ;     /* Offset in file to the tag's header info. */
  967.    int         root_write ;        /* True if 'header.root' needs to be written */
  968.    int         key_dec ;
  969.    LIST4       saved ;
  970.    int         debug_int ;         /* used to check structure integrity (set to 0x5281) */
  971.    #ifdef S4MDX
  972.       long  changed ;
  973.    #endif
  974. } TAG4 ;
  975.  
  976. typedef struct
  977. {
  978.    char S4PTR  *name ;
  979.    char S4PTR  *expression ;
  980.    char S4PTR  *filter ;
  981.    int unique ;
  982.    unsigned int descending ;
  983. } TAG4INFO ;
  984.  
  985. typedef struct INDEX4_st
  986. {
  987.    LINK4  link ;
  988.  
  989.    FILE4  file ;
  990.    DATA4 S4PTR *data ;
  991.    CODE4 S4PTR *code_base ;
  992.    LIST4  tags ;
  993.  
  994.    #ifdef S4FOX
  995.       TAG4 *tag_index ;    /* the tags are a tag in the index file! */
  996.       long  eof ;
  997.    #else
  998.       #ifdef N4OTHER
  999.          char alias[11] ;
  1000.         char *path ;
  1001.       #else
  1002.          I4HEADER header ;
  1003.       #endif
  1004.    #endif
  1005.  
  1006.    MEM4 S4PTR *block_memory ;
  1007.    int   file_locked ;    /* True if locked */
  1008.    #ifdef S4FOX
  1009.       unsigned long  version_old ;
  1010.    #else
  1011.       #ifdef S4MDX
  1012.          long  changed ;
  1013.       #else
  1014.          long  version_old ;
  1015.       #endif
  1016.    #endif
  1017. } INDEX4 ;
  1018.  
  1019.  
  1020. /* Memo File Structures */
  1021.  
  1022. typedef struct
  1023. {
  1024.    #ifdef S4MFOX
  1025.       long  next_block ;  /* Memo Entry 1,2, ... */
  1026.       char  usused[2] ;
  1027.       short block_size ;  /* Bytes */
  1028.    #else
  1029.       #ifdef S4MNDX
  1030.          long  next_block ;  /* Memo Entry 1,2, ... */
  1031.       #else
  1032.          long  next_block ;  /* Memo Entry 1,2, ... */
  1033.          long  zero ;
  1034.          char  file_name[8] ;
  1035.          short zero2 ;
  1036.          short x102 ;
  1037.          short block_size ;  /* Bytes */
  1038.          short zero3 ;
  1039.       #endif
  1040.    #endif
  1041. } MEMO4HEADER ;
  1042.  
  1043. #ifndef S4MNDX
  1044. #ifndef S4MFOX
  1045. typedef struct
  1046. {
  1047.    long  next ;       /* The next free block area */
  1048.    long  num ;        /* The number of free blocks in the free block area */
  1049.    int   to_disk ;    /* TRUE if this information needs to be written to disk */
  1050.    long  block_no ;   /* The current block number */
  1051. } MEMO4CHAIN_ENTRY ;
  1052. #endif /*  ifndef S4MFOX  */
  1053.  
  1054. typedef struct
  1055. {
  1056.    #ifdef S4MFOX
  1057.       long  type ;         /* 0 for picture, 1 for text -- picture not supported */
  1058.       long  num_chars ;    /* Including the 'MemoBlock' */
  1059.    #else
  1060.       short minus_one ;    /* '-1' for dBASE IV */
  1061.       short start_pos ;
  1062.       long  num_chars ;    /* Including the 'MemoBlock' */
  1063.    #endif
  1064. } MEMO4BLOCK ;
  1065. #endif  /*  ifndef S4MNDX  */
  1066.  
  1067. typedef struct
  1068. {
  1069.    unsigned  char  sig_dig ;  /* The number of significant digits; 52 is zero */
  1070.    unsigned  char  digit_info ; /* contains one, len and sign */
  1071.    unsigned  char  bcd[10] ;
  1072. }  C4BCD ;
  1073.  
  1074. #ifdef __cplusplus
  1075.    extern "C" {
  1076. #endif
  1077.  
  1078. void   S4FUNCTION date4assign( char S4PTR *, long ) ;
  1079. long   S4FUNCTION date4long( char S4PTR * ) ;  /* Date Arithmetic */
  1080. char S4PTR * S4FUNCTION date4cdow( char S4PTR * ) ;
  1081. char S4PTR * S4FUNCTION date4cmonth( char S4PTR * ) ;
  1082. int    S4FUNCTION date4day( char S4PTR * ) ;
  1083. int    S4FUNCTION date4dow( char S4PTR * ) ;
  1084. void   S4FUNCTION date4format( char S4PTR *, char S4PTR *, char S4PTR * ) ;/* 'dt' may be 'result'*/
  1085. double S4FUNCTION date4format_mdx( char * ) ;
  1086. int    S4FUNCTION date4format_mdx2( char * , double * ) ;
  1087. void   S4FUNCTION date4init( char S4PTR *, char S4PTR *, char S4PTR * ) ;
  1088. int    S4FUNCTION date4month( char S4PTR * ) ;
  1089. void   S4FUNCTION date4today( char S4PTR * ) ;
  1090. int    S4FUNCTION date4year( char S4PTR * ) ;
  1091. void   S4FUNCTION date4time_now( char S4PTR * ) ;
  1092.  
  1093. int    S4FUNCTION b4skip( B4BLOCK S4PTR *, long ) ;
  1094.  
  1095. #ifdef S4NDX
  1096.    int S4FUNCTION b4find( B4BLOCK S4PTR *, long, B4BLOCK S4PTR * ) ;
  1097.    int S4FUNCTION b4get_last_key( B4BLOCK S4PTR *, char S4PTR * ) ;
  1098.    int S4FUNCTION i4get_last_key( TAG4 S4PTR *,char S4PTR *, long ) ;
  1099. #endif
  1100.  
  1101. #ifdef S4CLIPPER
  1102.    void S4FUNCTION b4copy( B4BLOCK *, B4BLOCK * ) ;
  1103. #endif
  1104.  
  1105. #ifdef S4FOX
  1106. int    S4FUNCTION b4calc_blanks( char S4PTR *, int, char ) ;
  1107. int    S4FUNCTION b4calc_dups( char S4PTR *, char S4PTR *, int ) ;
  1108. void   S4FUNCTION b4go( B4BLOCK S4PTR *, int ) ;
  1109. int    S4FUNCTION b4insert_leaf( B4BLOCK S4PTR *, void S4PTR *, long ) ;
  1110. int    S4FUNCTION b4insert_branch( B4BLOCK S4PTR *, void S4PTR *, long, long, char ) ;
  1111. void   S4FUNCTION b4leaf_init( B4BLOCK * ) ;
  1112. int    S4FUNCTION b4leaf_seek( B4BLOCK S4PTR *, char S4PTR *, int ) ;
  1113. int    S4FUNCTION b4rec_len( long ) ;
  1114. int    S4FUNCTION b4reindex( B4BLOCK S4PTR * ) ;
  1115. void   S4FUNCTION b4remove_leaf( B4BLOCK S4PTR * ) ;
  1116. void   S4FUNCTION b4br_replace( B4BLOCK S4PTR *, char S4PTR *, long ) ;
  1117. void   S4FUNCTION b4top( B4BLOCK S4PTR * ) ;
  1118. int    S4CALL     t4desc_memcmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1119. void   S4FUNCTION t4branch_split( TAG4 S4PTR *, B4BLOCK S4PTR *, B4BLOCK S4PTR * ) ;
  1120. void   S4FUNCTION t4leaf_split( TAG4 S4PTR *, B4BLOCK S4PTR *, B4BLOCK S4PTR * ) ;
  1121. int    S4FUNCTION t4r_seek( TAG4 S4PTR *, void S4PTR *, int, long ) ;
  1122. int    S4FUNCTION t4rl_bottom( TAG4 * ) ;
  1123. int    S4FUNCTION t4rl_top( TAG4 * ) ;
  1124. int    S4FUNCTION b4r_brseek( B4BLOCK S4PTR *, char S4PTR *, int, long ) ;
  1125. long   S4FUNCTION x4recno( B4BLOCK S4PTR *, int ) ;
  1126. int    S4FUNCTION x4dup_cnt( B4BLOCK S4PTR *, int ) ;
  1127. int    S4FUNCTION x4trail_cnt( B4BLOCK S4PTR *, int ) ;
  1128. void   S4FUNCTION x4put_info( B4NODE_HEADER S4PTR *, void S4PTR *, long, int, int ) ;
  1129. int    S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long, long, char ) ;
  1130. int    S4FUNCTION t4init( TAG4 S4PTR *, INDEX4 S4PTR *, long, char S4PTR *) ;
  1131. #else
  1132.    #ifdef N4OTHER
  1133.       void   S4FUNCTION b4append( B4BLOCK S4PTR *, long ) ;
  1134.       void   S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long, long ) ;
  1135.       #ifdef S4CLIPPER
  1136.          int    S4FUNCTION c4clip( char S4PTR *, int ) ;
  1137.          void   S4FUNCTION b4append2( B4BLOCK S4PTR *, void S4PTR *, long, long ) ;
  1138.          void   S4FUNCTION t4remove_ref( TAG4 S4PTR * ) ;
  1139.          int    S4FUNCTION t4get_replace_entry( TAG4 S4PTR *, B4KEY_DATA S4PTR *, B4BLOCK S4PTR * ) ;
  1140.          int    S4FUNCTION t4shrink( TAG4 S4PTR *, long ) ;
  1141.       #endif
  1142.       int    S4FUNCTION b4room( B4BLOCK S4PTR * ) ;
  1143.       int    S4FUNCTION t4close( TAG4 S4PTR * ) ;
  1144.       long   S4FUNCTION t4extend( TAG4 S4PTR * ) ;
  1145.       int    S4FUNCTION t4lock( TAG4 * ) ;
  1146.       int    S4FUNCTION t4unlock( TAG4 * ) ;
  1147.       TAG4  S4PTR *S4FUNCTION t4open( DATA4 S4PTR *, INDEX4 S4PTR *, char S4PTR * ) ;
  1148.       int    S4FUNCTION t4update_header( TAG4 S4PTR * ) ;
  1149.       int    S4FUNCTION t4do_version_check( TAG4 S4PTR *, int ) ;
  1150.       TAG4  S4PTR *S4FUNCTION t4create( DATA4 S4PTR *, TAG4INFO S4PTR *, INDEX4 S4PTR * ) ;
  1151.       int    S4FUNCTION t4reindex( TAG4 S4PTR * ) ;
  1152.       void   S4FUNCTION t4remove_branch( TAG4 *, B4BLOCK * ) ;
  1153.    #else
  1154.       void   S4FUNCTION b4insert( B4BLOCK S4PTR *, void S4PTR *, long ) ;
  1155.       int    S4FUNCTION t4init( TAG4 S4PTR *, INDEX4 S4PTR *, T4DESC S4PTR * ) ;
  1156.    #endif
  1157. #endif
  1158.  
  1159. B4BLOCK S4PTR *S4FUNCTION b4alloc( TAG4 S4PTR *, long ) ;
  1160. int    S4FUNCTION b4flush( B4BLOCK S4PTR * ) ;
  1161. void   S4FUNCTION b4free( B4BLOCK S4PTR * ) ;
  1162. void   S4FUNCTION b4go_eof( B4BLOCK S4PTR * ) ;
  1163. B4KEY_DATA S4PTR * S4FUNCTION b4key( B4BLOCK S4PTR *, int ) ;
  1164. unsigned char S4PTR * S4FUNCTION b4key_key( B4BLOCK S4PTR *, int ) ;
  1165. int    S4FUNCTION b4lastpos( B4BLOCK S4PTR * ) ;
  1166. int    S4FUNCTION b4leaf( B4BLOCK S4PTR * ) ;
  1167. long   S4FUNCTION b4recno( B4BLOCK S4PTR *, int ) ;
  1168. void   S4FUNCTION b4remove( B4BLOCK S4PTR *);
  1169. int    S4FUNCTION b4seek( B4BLOCK S4PTR *, char S4PTR *, int ) ;
  1170.  
  1171. double S4FUNCTION c4atod( char S4PTR *, int) ;
  1172. int    S4FUNCTION c4atoi( char S4PTR *, int) ;
  1173. long   S4FUNCTION c4atol( char S4PTR *, int) ;
  1174.  
  1175. #ifndef S4FOX
  1176.    #ifdef S4UNIX
  1177.       void c4bcd_from_a( char S4PTR *, char S4PTR *, int ) ;
  1178.       void t4str_to_date_mdx( char S4PTR *, char S4PTR *, int ) ;
  1179.       void t4no_change_str( char S4PTR *, char S4PTR *, int ) ;
  1180.       void c4bcd_from_d( char S4PTR *, double ) ;
  1181.       void t4no_change_double( char S4PTR *, double ) ;
  1182.    #else
  1183.       C4STOK c4bcd_from_a ;
  1184.       C4DTOK c4bcd_from_d ;
  1185.    #endif
  1186. #else
  1187.    C4STOK t4dtstr_to_fox ;
  1188.    C4STOK t4str_to_fox ;
  1189.    C4DTOK t4dbl_to_fox ;
  1190. #endif
  1191.  
  1192. void   S4FUNCTION c4dtoa_clipper( double, char S4PTR *, int, int ) ;
  1193. void   S4FUNCTION c4dtoa45( double, char S4PTR *, int, int) ;
  1194. void   S4FUNCTION c4encode( char S4PTR *, char S4PTR *, char S4PTR *, char S4PTR *) ;
  1195. void   S4FUNCTION c4lower( char S4PTR * ) ;
  1196. void   S4FUNCTION c4ltoa45( long, char S4PTR *, int) ;
  1197. void   S4FUNCTION c4trim_n( char S4PTR *, int ) ;
  1198. void   S4FUNCTION c4upper( char S4PTR * ) ;
  1199.  
  1200. #ifdef S4VBASIC
  1201.    int c4parm_check( void *, int, char * ) ;
  1202. #endif
  1203.  
  1204. int    S4FUNCTION d4changed( DATA4 S4PTR *, int ) ;
  1205. char S4PTR * S4FUNCTION d4alias( DATA4 S4PTR * ) ;
  1206. void   S4FUNCTION d4alias_set( DATA4 S4PTR *, char S4PTR * ) ;
  1207. int    S4FUNCTION d4append( DATA4 S4PTR * ) ;
  1208. int    S4FUNCTION d4append_data( DATA4 S4PTR * ) ;
  1209. int    S4FUNCTION d4append_blank( DATA4 S4PTR * ) ;
  1210. int    S4FUNCTION d4append_start( DATA4 S4PTR *, int ) ;
  1211. void   S4FUNCTION d4blank( DATA4 S4PTR * ) ;
  1212. int    S4FUNCTION d4bof( DATA4 S4PTR * ) ;
  1213. int    S4FUNCTION d4bottom( DATA4 S4PTR * ) ;
  1214. int    S4FUNCTION d4check( DATA4 S4PTR * ) ;
  1215. int    S4FUNCTION d4close( DATA4 S4PTR * ) ;
  1216. int    S4FUNCTION d4close_all( CODE4 S4PTR * ) ;
  1217. DATA4 S4PTR * S4FUNCTION d4create( CODE4 S4PTR *, char S4PTR *, FIELD4INFO S4PTR *, TAG4INFO S4PTR * ) ;
  1218. DATA4 S4PTR * S4FUNCTION d4data( CODE4 S4PTR *, char S4PTR * ) ;
  1219. void   S4FUNCTION d4delete( DATA4 S4PTR * ) ;
  1220. int    S4FUNCTION d4deleted( DATA4 S4PTR * ) ;
  1221. int    S4FUNCTION d4eof( DATA4 S4PTR * ) ;
  1222. FIELD4 S4PTR * S4FUNCTION d4field( DATA4 S4PTR *, char S4PTR * ) ;
  1223. FIELD4INFO S4PTR * S4FUNCTION d4field_info( DATA4 * ) ;
  1224. FIELD4 S4PTR * S4FUNCTION d4field_j( DATA4 S4PTR *, int ) ;
  1225. int    S4FUNCTION d4field_number( DATA4 S4PTR *, char S4PTR * ) ;
  1226. int    S4FUNCTION d4flush( DATA4 S4PTR * ) ;
  1227. int    S4FUNCTION d4flush_data( DATA4 * ) ;
  1228. int    S4FUNCTION d4flush_files( CODE4 S4PTR * ) ;
  1229. int    S4FUNCTION d4free_blocks( DATA4 S4PTR * ) ;
  1230. int    S4FUNCTION d4go( DATA4 S4PTR *, long ) ;
  1231. int    S4FUNCTION d4go_data( DATA4 S4PTR *, long ) ;
  1232. int    S4FUNCTION d4go_eof( DATA4 S4PTR * ) ;
  1233. INDEX4 S4PTR * S4FUNCTION d4index( DATA4 S4PTR *, char S4PTR * ) ;
  1234. void   S4FUNCTION d4init( CODE4 S4PTR * ) ;
  1235. int    S4FUNCTION d4init_undo( CODE4 S4PTR * ) ;
  1236. int    S4FUNCTION d4lock( DATA4 S4PTR *, long ) ;
  1237. int    S4FUNCTION d4lock_all( DATA4 * ) ;
  1238. int    S4FUNCTION d4lock_append( DATA4 S4PTR * ) ;
  1239. int    S4FUNCTION d4lock_file( DATA4 S4PTR * ) ;
  1240. int    S4FUNCTION d4lock_index( DATA4 S4PTR * ) ;
  1241. int    S4FUNCTION d4lock_group( DATA4 S4PTR *, long S4PTR *, int ) ;
  1242. int    S4FUNCTION d4lock_test( DATA4 S4PTR *, long ) ;
  1243. int    S4FUNCTION d4lock_test_file( DATA4 S4PTR * ) ;
  1244. int    S4FUNCTION d4lock_test_append( DATA4 S4PTR * ) ;
  1245. int    S4FUNCTION d4lock_test_index( DATA4 S4PTR * ) ;
  1246. int    S4FUNCTION d4memo_compress( DATA4 S4PTR * ) ;
  1247. int    S4FUNCTION d4num_fields( DATA4 S4PTR * ) ;
  1248. DATA4 S4PTR *S4FUNCTION d4open( CODE4 S4PTR *, char S4PTR * ) ;
  1249. int    S4FUNCTION d4opt_start( CODE4 S4PTR * ) ;
  1250. int    S4FUNCTION d4opt_suspend( CODE4 S4PTR * ) ;
  1251. int    S4FUNCTION d4optimize( DATA4 S4PTR *, int ) ;
  1252. int    S4FUNCTION d4optimize_write( DATA4 S4PTR *, int ) ;
  1253. int    S4FUNCTION d4pack( DATA4 S4PTR * ) ;
  1254. int    S4FUNCTION d4pack_data( DATA4 S4PTR * ) ;
  1255. int    S4FUNCTION d4position2( DATA4 S4PTR *, double S4PTR * ) ;
  1256. double S4FUNCTION d4position( DATA4 S4PTR * ) ;
  1257. int    S4FUNCTION d4position_set( DATA4 S4PTR *, double ) ;
  1258. int    S4FUNCTION d4read( DATA4 S4PTR *, long, char S4PTR * ) ;
  1259. int    S4FUNCTION d4read_old( DATA4 S4PTR *, long ) ;
  1260. void   S4FUNCTION d4recall( DATA4 S4PTR * ) ;
  1261. long   S4FUNCTION d4reccount( DATA4 S4PTR * ) ;
  1262. long   S4FUNCTION d4recno( DATA4 S4PTR * ) ;
  1263. char  S4PTR *S4FUNCTION d4record( DATA4 S4PTR * ) ;
  1264. long   S4FUNCTION d4record_position( DATA4 S4PTR *, long ) ;
  1265. long   S4FUNCTION d4record_width( DATA4 S4PTR * ) ;
  1266. int    S4FUNCTION d4refresh( DATA4 * ) ;
  1267. int    S4FUNCTION d4refresh_record( DATA4 * ) ;
  1268. int    S4FUNCTION d4reindex( DATA4 S4PTR * ) ;
  1269. int    S4FUNCTION d4seek( DATA4 S4PTR *, char S4PTR * ) ;
  1270. int    S4FUNCTION d4seek_double( DATA4 S4PTR *, double ) ;
  1271. int    S4FUNCTION d4skip( DATA4 S4PTR *, long ) ;
  1272. TAG4 S4PTR *S4FUNCTION d4tag( DATA4 S4PTR *, char S4PTR * ) ;
  1273. TAG4 S4PTR *S4FUNCTION d4tag_default( DATA4 S4PTR * ) ;
  1274. TAG4 S4PTR *S4FUNCTION d4tag_next( DATA4 S4PTR *, TAG4 S4PTR * ) ;
  1275. TAG4 S4PTR *S4FUNCTION d4tag_prev( DATA4 S4PTR *, TAG4 S4PTR * ) ;
  1276. void   S4FUNCTION d4tag_select( DATA4 S4PTR *, TAG4 S4PTR * ) ;
  1277. TAG4 S4PTR *S4FUNCTION d4tag_selected( DATA4 S4PTR * ) ;
  1278. int    S4FUNCTION d4top( DATA4 S4PTR * ) ;
  1279. int    S4FUNCTION d4unlock( DATA4 S4PTR * ) ;
  1280. int    S4FUNCTION d4unlock_data( DATA4 S4PTR * ) ;
  1281. int    S4FUNCTION d4unlock_files( CODE4 S4PTR * ) ;
  1282. int    S4FUNCTION d4unlock_append( DATA4 S4PTR * ) ;
  1283. int    S4FUNCTION d4unlock_file( DATA4 S4PTR * ) ;
  1284. int    S4FUNCTION d4unlock_index( DATA4 S4PTR * ) ;
  1285. int    S4FUNCTION d4unlock_records( DATA4 S4PTR * ) ;
  1286. int    S4FUNCTION d4update( DATA4 S4PTR * ) ;
  1287. int    S4FUNCTION d4update_header( DATA4 S4PTR *, int, int ) ;
  1288. int    S4FUNCTION d4update_record( DATA4 S4PTR *, int ) ;
  1289. int    S4FUNCTION d4validate_memo_ids( DATA4 S4PTR * ) ;
  1290. int    S4FUNCTION d4write( DATA4 S4PTR *, long ) ;
  1291. int    S4FUNCTION d4write_data( DATA4 S4PTR *, long ) ;
  1292. int    S4FUNCTION d4write_keys( DATA4 S4PTR *, long ) ;
  1293. int    S4FUNCTION d4zap( DATA4 S4PTR *, long, long ) ;
  1294. int    S4FUNCTION d4zap_data( DATA4 S4PTR *, long, long ) ;
  1295.  
  1296. void   S4FUNCTION e4exit(CODE4 S4PTR *) ;
  1297. void   S4FUNCTION e4exit_test( CODE4 S4PTR * ) ;
  1298.  
  1299. int    S4FUNCTION e4( CODE4 S4PTR *, int, char * ) ;
  1300. int    S4FUNCTION e4code( CODE4 S4PTR * ) ;
  1301. int    S4FUNCTION e4describe( CODE4 S4PTR * ,int, char *, char *, char * ) ;
  1302. void   S4FUNCTION e4hook( CODE4 S4PTR *c4, int err_code, char *desc1, char *desc2, char *desc3 ) ;
  1303. int    S4FUNCTION e4set( CODE4 S4PTR *, int ) ;
  1304. void   S4FUNCTION e4severe( int, char * ) ;
  1305. char * S4FUNCTION e4text( int err_code ) ;
  1306. #ifdef S4VBASIC
  1307.    void   S4ERROR   e4severe_vbasic( int, char * ) ;
  1308. #endif
  1309.  
  1310. void   S4FUNCTION f4assign( FIELD4 S4PTR *, char S4PTR * ) ;
  1311. void   S4FUNCTION f4assign_char( FIELD4 S4PTR *, int ) ;
  1312. void   S4FUNCTION f4assign_double( FIELD4 S4PTR *, double ) ;
  1313. void   S4FUNCTION f4assign_field( FIELD4 S4PTR *, FIELD4 S4PTR * ) ;
  1314. void   S4FUNCTION f4assign_int( FIELD4 S4PTR *, int ) ;
  1315. void   S4FUNCTION f4assign_long( FIELD4 S4PTR *, long ) ;
  1316. void   S4FUNCTION f4assign_n( FIELD4 S4PTR *, char S4PTR *, unsigned ) ;
  1317. char S4PTR * S4FUNCTION f4assign_ptr( FIELD4 S4PTR * ) ;
  1318. void   S4FUNCTION f4blank( FIELD4 S4PTR * ) ;
  1319. int    S4FUNCTION f4char( FIELD4 S4PTR * ) ;
  1320. DATA4 S4PTR *S4FUNCTION f4data( FIELD4 S4PTR * ) ;
  1321. int    S4FUNCTION f4decimals( FIELD4 S4PTR * ) ;
  1322. int    S4FUNCTION f4double2( FIELD4 S4PTR *, double S4PTR * ) ;
  1323. double S4FUNCTION f4double( FIELD4 S4PTR * ) ;
  1324. int    S4FUNCTION f4int( FIELD4 S4PTR * ) ;
  1325. unsigned  S4FUNCTION f4len( FIELD4 S4PTR * ) ;
  1326. long   S4FUNCTION f4long( FIELD4 S4PTR * ) ;
  1327. char S4PTR * S4FUNCTION f4name( FIELD4 S4PTR * ) ;
  1328. unsigned S4FUNCTION f4ncpy( FIELD4 S4PTR *, char S4PTR *, unsigned ) ;
  1329. char S4PTR * S4FUNCTION f4ptr( FIELD4 S4PTR * ) ;
  1330. char S4PTR * S4FUNCTION f4str( FIELD4 S4PTR * ) ;
  1331. int    S4FUNCTION f4true( FIELD4 S4PTR * ) ;
  1332. int    S4FUNCTION f4type( FIELD4 S4PTR * ) ;
  1333.  
  1334. int    S4FUNCTION file4close( FILE4 S4PTR * ) ;
  1335. int    S4FUNCTION file4create( FILE4 S4PTR *, CODE4 S4PTR *, char S4PTR *, int ) ;
  1336. int    S4FUNCTION file4flush( FILE4 S4PTR * ) ;
  1337. int    S4FUNCTION file4low_flush( FILE4 S4PTR *, int ) ;
  1338. long   S4FUNCTION file4len( FILE4 S4PTR * ) ;
  1339. int    S4FUNCTION file4len_set( FILE4 S4PTR *, long ) ;
  1340. int    S4FUNCTION file4lock( FILE4 S4PTR *, long, long ) ;
  1341. int    S4FUNCTION file4lock_hook( CODE4 *cb, char *file_name, long offset, long num_bytes, int num_tries ) ;
  1342. int    S4FUNCTION file4open( FILE4 S4PTR *, CODE4 S4PTR *, char S4PTR *, int ) ;
  1343. int    S4FUNCTION file4open_test( FILE4 S4PTR * ) ;
  1344. int    S4FUNCTION file4optimize( FILE4 S4PTR *, int, int ) ;
  1345. int    S4FUNCTION file4optimize_write( FILE4 S4PTR *, int ) ;
  1346. unsigned  S4FUNCTION file4read( FILE4 S4PTR *, long, void S4PTR *, unsigned ) ;
  1347. int    S4FUNCTION file4read_all( FILE4 S4PTR *, long, void S4PTR *, unsigned ) ;
  1348. int    S4FUNCTION file4read_error( FILE4 S4PTR * ) ;
  1349. int    S4FUNCTION file4refresh( FILE4 S4PTR * ) ;
  1350. int    S4FUNCTION file4replace( FILE4 S4PTR *, FILE4 S4PTR * ) ;
  1351. int    S4FUNCTION file4temp( FILE4 S4PTR *, CODE4 S4PTR *, char S4PTR *, int ) ;
  1352. int    S4FUNCTION file4unlock( FILE4 S4PTR *, long, long ) ;
  1353. int    S4FUNCTION file4write( FILE4 S4PTR *, long, void S4PTR *, unsigned ) ;
  1354.  
  1355. void   S4FUNCTION file4seq_read_init( FILE4SEQ_READ S4PTR *, FILE4 S4PTR *, long, void S4PTR *, unsigned ) ;
  1356. unsigned  S4FUNCTION file4seq_read( FILE4SEQ_READ S4PTR *, void S4PTR *, unsigned ) ;
  1357. int    S4FUNCTION file4seq_read_all( FILE4SEQ_READ S4PTR *, void S4PTR *, unsigned ) ;
  1358.  
  1359. void   S4FUNCTION file4seq_write_init( FILE4SEQ_WRITE S4PTR *, FILE4 S4PTR *, long, void S4PTR *, unsigned ) ;
  1360. int    S4FUNCTION file4seq_write( FILE4SEQ_WRITE S4PTR *, void S4PTR *, unsigned ) ;
  1361. int    S4FUNCTION file4seq_write_flush( FILE4SEQ_WRITE S4PTR * ) ;
  1362. int    S4FUNCTION file4seq_write_repeat( FILE4SEQ_WRITE S4PTR *, long, char ) ;
  1363.  
  1364. int    S4FUNCTION i4check( INDEX4 S4PTR * ) ;
  1365. int    S4FUNCTION i4close( INDEX4 S4PTR * ) ;
  1366. INDEX4 S4PTR *S4FUNCTION i4create( DATA4 S4PTR *, char S4PTR *, TAG4INFO S4PTR * ) ; /* 0 name -> productn */
  1367. long   S4FUNCTION i4extend( INDEX4 S4PTR * ) ;   /* Allocates a block at the end of the file */
  1368. int    S4FUNCTION i4flush( INDEX4 S4PTR * ) ;
  1369. int    S4FUNCTION i4lock( INDEX4 S4PTR * ) ;
  1370. INDEX4 S4PTR *S4FUNCTION i4open( DATA4 S4PTR *, char S4PTR * ) ;
  1371. int    S4FUNCTION i4read_block( FILE4 S4PTR *, long, B4BLOCK S4PTR *, B4BLOCK S4PTR * ) ;
  1372. int    S4FUNCTION i4reindex( INDEX4 S4PTR * ) ;
  1373. int    S4FUNCTION i4shrink( INDEX4 S4PTR *, long ) ;  /* Returns a block of disk space */
  1374. TAG4 S4PTR *S4FUNCTION i4tag( INDEX4 S4PTR *, char S4PTR * ) ;
  1375. TAG4INFO *S4FUNCTION i4tag_info( INDEX4 * ) ;
  1376. int    S4FUNCTION i4unlock( INDEX4 S4PTR * ) ;
  1377. int    S4FUNCTION i4update( INDEX4 S4PTR * ) ;
  1378. int    S4FUNCTION i4update_header( INDEX4 S4PTR * ) ;
  1379. int    S4FUNCTION t4version_check( TAG4 S4PTR *, int ) ;
  1380. int    S4FUNCTION i4version_check( INDEX4 S4PTR *, int ) ;
  1381.  
  1382. void   S4FUNCTION l4add( LIST4 S4PTR *, void S4PTR * ) ;
  1383. void   S4FUNCTION l4add_after(   LIST4 S4PTR *, void S4PTR *, void S4PTR * ) ;
  1384. void   S4FUNCTION l4add_before( LIST4 S4PTR *, void S4PTR *, void S4PTR * ) ;
  1385. void   l4check( LIST4 S4PTR * ) ;
  1386. void S4PTR * S4FUNCTION l4first( LIST4 S4PTR * ) ;  /* Returns 0 if none */
  1387. void S4PTR * S4FUNCTION l4last( LIST4 S4PTR * ) ;   /* Returns 0 if none */
  1388. void S4PTR * S4FUNCTION l4next( LIST4 S4PTR *, void S4PTR * ) ;  /* Returns 0 if none */
  1389. void S4PTR * S4FUNCTION l4prev( LIST4 S4PTR *, void S4PTR * ) ;
  1390. void S4PTR * S4FUNCTION l4pop( LIST4 S4PTR * ) ;
  1391. void   S4FUNCTION l4remove( LIST4 S4PTR *, void S4PTR * ) ;
  1392. int    S4FUNCTION l4seek( LIST4 *, void * ) ;
  1393.  
  1394. int    S4FUNCTION l4lock_check( void ) ;
  1395. void   l4lock_remove( int,long,long) ;
  1396. void   l4lock_save( int, long, long ) ;
  1397.  
  1398. #ifndef S4MFOX
  1399. #ifndef S4MNDX
  1400. int    memo4file_chain_flush( MEMO4FILE S4PTR *, MEMO4CHAIN_ENTRY S4PTR * ) ;
  1401. int    memo4file_chain_skip( MEMO4FILE S4PTR *, MEMO4CHAIN_ENTRY S4PTR * ) ;
  1402. int    S4FUNCTION f4memo_check( MEMO4FILE S4PTR * ) ;
  1403. #endif  /*  ifndef S4MFOX  */
  1404. #endif  /*  ifndef S4MNDX  */
  1405.  
  1406. int    memo4file_check( MEMO4FILE S4PTR * ) ;
  1407. int    memo4file_create( MEMO4FILE S4PTR *, CODE4 S4PTR *, DATA4 S4PTR *, char S4PTR * );
  1408.           /* if (name == 0), it is a temporary file */
  1409. int    memo4file_dump( MEMO4FILE S4PTR *, long, char S4PTR *, unsigned ) ;
  1410. int    memo4file_open( MEMO4FILE S4PTR *, DATA4 S4PTR *, char S4PTR * ) ;
  1411. int    memo4file_read( MEMO4FILE S4PTR *, long , char S4PTR * S4PTR *, unsigned S4PTR * ) ;
  1412. int    memo4file_write( MEMO4FILE S4PTR *, long S4PTR *, char S4PTR *, unsigned ) ; /* Pass the old id */
  1413.  
  1414. int    S4FUNCTION f4memo_assign( FIELD4 S4PTR *, char S4PTR * ) ;
  1415. int    S4FUNCTION f4memo_assign_n( FIELD4 S4PTR *, char S4PTR *, unsigned ) ;
  1416. unsigned S4FUNCTION f4memo_len( FIELD4 S4PTR * ) ;
  1417. unsigned S4FUNCTION f4memo_ncpy( FIELD4 S4PTR *, char S4PTR *, unsigned ) ;
  1418. int    S4FUNCTION f4memo_set_len( FIELD4 S4PTR *, unsigned ) ;
  1419. char   S4PTR * S4FUNCTION f4memo_str( FIELD4 S4PTR * ) ;
  1420. char   S4PTR * S4FUNCTION f4memo_ptr( FIELD4 S4PTR * ) ;
  1421.  
  1422. int    S4FUNCTION f4memo_flush( FIELD4 S4PTR * ) ;
  1423. void   S4FUNCTION f4memo_free( FIELD4 S4PTR * ) ;
  1424. int    S4FUNCTION f4memo_read( FIELD4 S4PTR * ) ;       /* Validates memo id's first */
  1425. int    S4FUNCTION f4memo_read_low( FIELD4 S4PTR * ) ;   /* Assumes the current memo id is valid */
  1426. void   S4FUNCTION f4memo_reset( FIELD4 S4PTR * ) ;      /* Resets to 'Unknown state' */
  1427. int    S4FUNCTION f4memo_update( FIELD4 S4PTR * ) ;
  1428. int    S4FUNCTION f4memo_write( FIELD4 S4PTR * ) ;
  1429. int    S4FUNCTION memo4file_lock( MEMO4FILE S4PTR * ) ;
  1430. int    S4FUNCTION memo4file_unlock( MEMO4FILE S4PTR * ) ;
  1431.  
  1432. #ifdef S4CLIPPER
  1433. int    S4FUNCTION t4balance( TAG4 *, B4BLOCK *, int ) ;
  1434. #endif
  1435.  
  1436. #ifdef S4HAS_DESCENDING
  1437.    void   S4FUNCTION t4descending( TAG4 *, int ) ;
  1438. #endif
  1439.  
  1440. int    S4FUNCTION t4add( TAG4 S4PTR *, unsigned char S4PTR *, long ) ;  /* Returns r4unique, r4success, r4repeat */
  1441. int    S4FUNCTION t4add_calc( TAG4 S4PTR *, long ) ; /* Calculates expression and adds */
  1442. char  *S4FUNCTION t4alias( TAG4 * ) ;
  1443. B4BLOCK S4PTR *S4FUNCTION t4block( TAG4 S4PTR * ) ;
  1444. int    S4FUNCTION t4bottom( TAG4 S4PTR * ) ;
  1445. int    S4FUNCTION t4check( TAG4 S4PTR * ) ;
  1446. int    S4FUNCTION t4is_descending( TAG4 * ) ;
  1447. int    S4FUNCTION t4down( TAG4 S4PTR * ) ;
  1448. int    S4FUNCTION t4dump( TAG4 S4PTR *, int, int ) ;
  1449. int    S4FUNCTION t4eof( TAG4 S4PTR * ) ;
  1450. int    S4FUNCTION t4expr_key( TAG4 S4PTR *, char S4PTR * S4PTR * ) ;
  1451. int    S4FUNCTION t4flush( TAG4 S4PTR * ) ;
  1452. int    S4FUNCTION t4free_all( TAG4 S4PTR * ) ;
  1453. int    S4FUNCTION t4free_saved( TAG4 S4PTR * ) ;
  1454. int    S4FUNCTION t4go( TAG4 S4PTR *, char S4PTR *, long ) ;
  1455. void   S4FUNCTION t4init_seek_conv( TAG4 S4PTR *, int) ;    /* Initialize 'stok' and 'dtok' */
  1456. char S4PTR *S4FUNCTION t4key( TAG4 S4PTR * ) ;
  1457. B4KEY_DATA S4PTR *S4FUNCTION t4key_data( TAG4 S4PTR * ) ;              /* The current key */
  1458. void   S4FUNCTION t4out_of_date( TAG4 * ) ;
  1459. int    S4FUNCTION t4position2( TAG4 S4PTR *, double S4PTR * ) ;
  1460. double S4FUNCTION t4position( TAG4 S4PTR * ) ;              /* Returns the position as a percent */
  1461. int    S4FUNCTION t4position_set( TAG4 S4PTR *, double ) ;  /* Positions a percentage */
  1462. long   S4FUNCTION t4recno( TAG4 S4PTR * ) ;
  1463. int    S4FUNCTION t4remove_current( TAG4 S4PTR * ) ;        /* Remove the current key */
  1464. int    S4FUNCTION t4remove( TAG4 S4PTR *, char S4PTR *, long ) ;  /* Remove specified key */
  1465. int    S4FUNCTION t4remove_calc( TAG4 S4PTR *, long ) ; /* Calculates expression and removes */
  1466. int    S4FUNCTION t4seek( TAG4 S4PTR *, void S4PTR *, int ) ;    /* r4success, r4found, r4after, r4eof */
  1467. long   S4FUNCTION t4skip( TAG4 S4PTR *, long ) ;
  1468. #ifdef S4CLIPPER
  1469. B4BLOCK S4PTR *S4FUNCTION t4split( TAG4 S4PTR *, B4BLOCK S4PTR *, int ) ;
  1470. #else
  1471. B4BLOCK S4PTR *S4FUNCTION t4split( TAG4 S4PTR *, B4BLOCK S4PTR * ) ;
  1472. #endif
  1473. int    S4FUNCTION t4top( TAG4 S4PTR * ) ;
  1474. int    S4FUNCTION t4type( TAG4 S4PTR * ) ;
  1475. int    S4FUNCTION t4unique( TAG4 * ) ;
  1476. int    S4FUNCTION t4up( TAG4 S4PTR * ) ;
  1477. int    S4FUNCTION t4update( TAG4 S4PTR * ) ;
  1478. int    S4FUNCTION t4up_to_root( TAG4 S4PTR * ) ;
  1479.  
  1480. /* File name lengths include one extra null character at end */
  1481. void   S4FUNCTION u4delay_sec( void ) ;
  1482. int    S4FUNCTION u4name_char( unsigned char ) ;
  1483. void   S4FUNCTION u4name_ext( char S4PTR *, int, char S4PTR *, int ) ;
  1484. int    S4FUNCTION u4name_ret_ext( char *, int, char * ) ;
  1485. void   S4FUNCTION u4name_piece( char S4PTR *, int, char S4PTR *, int, int ) ;
  1486. int    S4FUNCTION u4name_path( char S4PTR *, int, char S4PTR * ) ;
  1487. long   S4FUNCTION u4switch( void ) ;
  1488.  
  1489. int S4FUNCTION file4commit( DATA4 S4PTR * ) ;
  1490. unsigned S4FUNCTION u4ncpy( char S4PTR *, char S4PTR *, unsigned ) ;
  1491. int    S4FUNCTION u4ptr_equal( void S4PTR *, void S4PTR * ) ;
  1492. int    S4FUNCTION u4remove( char S4PTR * ) ;
  1493. void   S4FUNCTION u4yymmdd( char S4PTR * ) ;
  1494. #ifndef S4NO_RENAME
  1495.    int    S4FUNCTION u4rename( char S4PTR *, char S4PTR * ) ;
  1496. #endif
  1497.  
  1498. #ifdef S4CLIPPER
  1499.    int   S4FUNCTION c4descend( FIELD4 S4PTR *, char S4PTR *, int ) ;
  1500.    char *S4FUNCTION c4descend_str( char S4PTR *, char S4PTR *, int ) ;
  1501.    char *S4FUNCTION c4descend_date( char S4PTR *, long, int );
  1502.    char *S4FUNCTION c4descend_num( char S4PTR *, char S4PTR *, int ) ;
  1503. #endif
  1504.  
  1505. void  S4PTR *S4FUNCTION u4alloc( long ) ;
  1506. void  S4PTR *S4FUNCTION u4alloc_er( CODE4 S4PTR *, long ) ;
  1507. void  S4PTR *S4FUNCTION u4alloc_free( CODE4 S4PTR *, long ) ;
  1508. int    S4FUNCTION u4alloc_again( CODE4 S4PTR *, char S4PTR * S4PTR *, unsigned S4PTR *, unsigned ) ;
  1509. void   S4FUNCTION u4free( void S4PTR * ) ;
  1510. void   S4FUNCTION u4name_make( char *, int, char *, char *, char * ) ;
  1511. short  S4FUNCTION x4reverse_short( short ) ;
  1512. long   S4FUNCTION x4reverse_long( long ) ;
  1513.  
  1514. void  S4PTR *S4FUNCTION mem4alloc( MEM4 S4PTR * ) ;  /* 0 Parm causes 0 return */
  1515. void  S4PTR *S4FUNCTION mem4alloc2( MEM4 S4PTR *, CODE4 S4PTR * ) ;  /* 0 Parm causes 0 return */
  1516. Y4CHUNK S4PTR *S4FUNCTION mem4alloc_chunk( MEM4 S4PTR * ) ;  /* 0 Parm causes 0 return */
  1517. void   S4FUNCTION mem4free( MEM4 S4PTR *, void S4PTR * ) ;
  1518. int    S4FUNCTION mem4free_check( int ) ;
  1519. void   S4FUNCTION mem4check_memory( void ) ;
  1520. void   S4FUNCTION mem4init( void ) ;
  1521. #ifdef S4OLD_CODE
  1522. MEM4 S4PTR *S4FUNCTION mem4type( int, unsigned, int, int ) ;
  1523. #endif
  1524. MEM4 S4PTR *S4FUNCTION mem4create( CODE4 S4PTR *, int, unsigned, int, int ) ;
  1525. void  S4PTR *S4FUNCTION mem4create_alloc( CODE4 S4PTR *, MEM4 S4PTR * S4PTR *, int, unsigned, int, int ) ;
  1526. void   S4FUNCTION mem4release( MEM4 S4PTR * ) ;
  1527. void   S4FUNCTION mem4reset( void ) ;
  1528.  
  1529. #ifdef __cplusplus
  1530.    }
  1531. #endif
  1532.  
  1533. int S4CALL u4memcmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1534. #ifndef S4FOX
  1535. #ifndef S4CLIPPER
  1536.    int S4CALL c4bcd_cmp( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1537.    int S4CALL t4cmp_doub( S4CMP_PARM, S4CMP_PARM, size_t ) ;
  1538. #endif
  1539. #endif
  1540.